const CRUD = {
	swal: window.swal,
	delete: function (model, $id, msg='确认删除吗?'){
   
		this.showConfirmMessage(msg, '', 'warning', '确定',  function () {
	       $.post('/admin/'+model+'/'+$id, {
	       		'_token' : $("meta[name='csrf-token']").attr('content'),
	       		'_method': 'DELETE'
	       }, function (rsp){
	       		if(rsp != 'error'){
	       			console.log("#d"+$id);
	       			$("#d-"+$id).remove();
	       			CRUD.showSuccess('删除成功', '');
	       		}
	       })
	    });
	},
	showConfirmMessage : function (msg='', text='', type='warning', confirmText = '确定', callback) {
	    swal({
	        title: msg,
	        text: text,
	        type: type,
	        showCancelButton: true,
	        confirmButtonColor: "#DD6B55",
	        confirmButtonText: confirmText,
	        cancelButtonText: '取消',
	        closeOnConfirm: false
	    }, callback);
	},
	showSuccess : function(title, text){
		 swal(title, text , "success");
	}

}


